JavaScript Array []
- Previous Page []
- Next Page new Array()
- Go to the Previous Level JavaScript Array Reference Manual
Definition and Usage
[ ]
The constructor is used to create a new array object.
Instance
Example 1
// Create an array const cars = ["Saab", "Volvo", "BMW"];
Example 2
Create an empty array and add values:
// Create an array const cars = []; // Add values to the array cars.push("Saab"); cars.push("Volvo"); cars.push("BMW");
Example 3
Using new Array()
Method to create an array:
// Create an array const cars = new Array(["Saab", "Volvo", "BMW"]);
Syntax
[iterable]
Parameter
Parameter | Description |
---|---|
iterable | Required. An iterable object containing values. |
Return Value
Type | Description |
---|---|
Array | New Array Object |
Browser Support
[]
The array constructor is a feature of ECMAScript1 (JavaScript 1997).
It is supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
- Previous Page []
- Next Page new Array()
- Go to the Previous Level JavaScript Array Reference Manual